#! /usr/bin/python
def d(n):
  s = 1
  t = n ** .5
  for i in xrange(2, int(t)+1):
    if n % i == 0: s += i + n / i
  if t == int(t): s -= t
  return s
 
abn = set()
s = 0
for n in range( 1, 20162 ):
  if d(n) > n:
    abn.add(n)
  if not any( (n-a in abn) for a in abn ):
    s += n
print "Answer to PE23 = ", s
